package com.xxx.userservice.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.function.Consumer;
import java.util.function.Function;

@Slf4j
@Configuration
public class FunctionConsumer {

    // 对接受到的消息进行处理（函数式编程）
    @Bean
    public Function<String, String> toUpperCase() {
        return String::toUpperCase;
    }

    // 创建消费者
    @Bean
    public Consumer<String> im() {
        return str -> {
            log.info("FunctionConsumer received message：" + str);
        };
    }
}
